Repository navigation
fix(static): a forward keeps its connections to the target (#556) - #557
Merged
Merged
Conversation
A static service's forward opened a new connection to the target for every request and closed it first, so each left a socket in TIME_WAIT for two minutes; an end-to-end suite drained Windows' ephemeral ports, and pages and API calls failed with ERR_ADDRESS_IN_USE or 502. devstack_node::connpool keeps idle HTTP/1.1 connections per key and gives a connection back once its answer is read to its end (GiveBack, which also handles a body of known length that hyper does not poll past its last frame). The forward uses it per target, and so does the hub's way to its daemons, which had the same flaw. Upgrades (WebSocket) and streams that do not end (SSE) keep their own connection. 2000 requests four at a time now open 4 connections to the target instead of 2001. The public link router keeps a connection per request: its dial is also its check that a link is still open (ADR-0110 amendment). Closes #556 Bug-Class: connection-per-request Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
forwardon a static service (0.49.1) opened a new connection to the target for every request and closed it first: each left a socket inTIME_WAITfor two minutes, and an end-to-end suite (4 workers, ~1000 tests) drained Windows' ephemeral ports (ERR_ADDRESS_IN_USE,502). The "no pool" was my decision while building ADR-0110, and wrong.devstack_node::connpool:Pool<K, B>keeps idle HTTP/1.1 connections per key (up to 32),sendresends on a new connection when a kept one was closed while idle, andGiveBackis the answer's body that returns the connection once read to its end — including a body of known length, which hyper does not poll past its last frame (the first version missed that; the count test caught it).staticsrv: each forward target uses the pool. Upgrades (WebSocket) and streams that do not end (SSE) keep their own connection.daemon_send) used a connection per request too; it now uses the same pool by daemon port, and its resend logic treats a kept connection the daemon closed while idle as unsent.linkrouter.rs) — itsDialis also its check that a host is still open, so a kept connection would pass a link its owner closed; the service proxy (proxy.rs) — already pools, tied to its drain.Closes #556
Verified (Windows)
TIME_WAITto the targetserve-static --forwardstaticsrv::tests::a_forward_reuses_its_connections_to_the_target: red onmain("30 requests one after another opened 30 connections"), green here, also 4 at a time (≤ 8).daemon_send_tests::the_hub_reuses_its_connections_to_a_daemon: red with reuse switched off ("20 requests opened 20 connections"), green here; the hub's resend tests unchanged and green.cargo fmt,cargo clippy -D warnings,cargo test --workspace.Bug class:
connection-per-request.🤖 Generated with Claude Code